package com.huanghuang.shuadan.serviceimpl.user;

import com.huanghuang.shuadan.common.annotation.log.Log;
import com.huanghuang.shuadan.common.aop.validation.Check;
import com.huanghuang.shuadan.manager.user.UserManager;
import com.huanghuang.shuadan.service.entity.base.BaseReqDTO;
import com.huanghuang.shuadan.service.entity.base.PageReqDTO;
import com.huanghuang.shuadan.service.entity.base.Result;
import com.huanghuang.shuadan.service.entity.req.UserRegisterReqDTO;
import com.huanghuang.shuadan.service.entity.req.UsernameReqDTO;
import com.huanghuang.shuadan.service.entity.res.UserResDTO;
import com.huanghuang.shuadan.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author suxiaoxiao
 * @Date 2019/7/13 23:35
 * @Version 1.0
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserManager userManager;

    @Log(description = "查询所有用户信息")
    @Override
    public Result<UserResDTO> queryAllUser(PageReqDTO pageReqDTO) {
        Check.check(pageReqDTO);
        Result<UserResDTO> result = userManager.queryAllUser(pageReqDTO);
        return result;
    }

    @Log(description = "根据查询用户信息")
    @Override
    public Result<UserResDTO> selectUserByUsername(UsernameReqDTO usernameReqDTO) {
        Check.check(usernameReqDTO);
        Result<UserResDTO> result = userManager.selectUserByUsername(usernameReqDTO);
        return result;
    }

    @Log(description = "注册用户")
    @Override
    public Result<Boolean> registerUser(UserRegisterReqDTO userRegisterReqDTO) {
        Check.check(userRegisterReqDTO);
        Result<Boolean> result = userManager.registerUser(userRegisterReqDTO);
        return result;
    }

    @Log(description = "用户登陆")
    @Override
    public Result<UserResDTO> login(UserRegisterReqDTO userRegisterReqDTO) {
        Check.check(userRegisterReqDTO);
        Result<UserResDTO> result = userManager.login(userRegisterReqDTO);
        return result;
    }

    @Log(description = "用户信息")
    @Override
    public Result<UserResDTO> info() {
        Result<UserResDTO> result = userManager.info();
        return result;
    }
}
